/**
 ----------------------
 1.当前文件是数据中心
 2.其他页面可以引入控制
 ----------------------
 */
import type { IQuery, TableConfig } from '@/api/config/types';
import type { AxTree } from '@/api/modules/ax/tree/types';
import { treeDelete, treeEdit } from './curd';
import { DeleteOutlined, EditOutlined } from '@ant-design/icons-vue';
import { hasPerm } from '@/utils/common/perm';
import { useAxTable } from '@/utils/common/hooks';

//查询条件
let queryObj: Partial<IQuery<Partial<AxTree>>> = {
  val: '',
};

export const treeTable = useAxTable<AxTree>({
  //用于表格单选索引
  rowKey: 'id',
  //必须唯一固定，存储窗口位置，表头等
  moduleName: 'AxTree',
  //搜索条件
  query: queryObj,
  //鼠标右键菜单数据
  contextmenu: [
    {
      title: '查看',
      label: '查看',
      key: 'list',
      onClick() {
        treeEdit();
      },
      icon: h(EditOutlined),
      disabled: hasPerm('ax:ax:list'),
    },
    {
      title: '删除',
      label: '删除',
      key: 'delete',
      icon: h(DeleteOutlined),
      onClick() {
        treeDelete();
      },
      disabled: hasPerm('ax:ax:remove'),
    },
  ],
});
